package com.cxy.controller;

import com.cxy.pojo.User;
import com.cxy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author 蔡心勇
 * @create 2022/3/14 - 9:27
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/addUser")
    public ModelAndView addUser(User user){
        ModelAndView modelAndView=new ModelAndView();
        System.out.println(user);
        int res = userService.addUser(user);
        if(res>0)modelAndView.addObject("msg","添加成功");
        else modelAndView.addObject("msg","失败");
        modelAndView.setViewName("success");
        return modelAndView;
    }
}
